package leetcode.linkedlist;

import leetcode.linkedlist.common.LinkedListUtils;
import leetcode.linkedlist.common.ListNode;

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution203 {
    public ListNode removeElements(ListNode head, int val) {
        return LinkedListUtils.removeElements(head, val);
    }
}

public class leetcode203 {
    public static void main(String[] args) {
        Solution203 solution203 = new Solution203();
        int[] nums = {1,2,6,3,4,5,6};
        int[] nums1 = {};
        int[] nums2 = {7,7,7,7};
        test203(solution203, nums, 6);
        test203(solution203, nums1, 1);
        test203(solution203, nums2, 7);
    }

    private static void test203(Solution203 solution203, int[] nums, int key) {
        ListNode head = LinkedListUtils.generateLinkedListByArray(nums);
        ListNode removeElements = solution203.removeElements(head, key);
        System.out.println(LinkedListUtils.getLinkedListVals(removeElements));
    }
}
